// import * as Request from '../request';
import { SuzhouDistrictMap } from '@config/map';
import { RankTOOL } from '@utils/index';

// 科创概览-企业资质 区域分布数据
export const QulificationAnalysisAPI = async (params, qualificationType) => {
  let url;
  switch (qualificationType) {
    case '科创企业':
    case '科技型中小企业':
      url = '/api/company/analysis';
      break;

    default:
      // 其它资质 走农行数据定制接口
      url = '/api/qulification/especial_region';
      break;
  }

  let res: any = [];
  try {
    // res = await Request.post(url, params);
    res = [];
  } catch (error) {
    console.log('request error:', url, error);
  }

  const rankedRes = RankTOOL(res, 'value');

  return SuzhouDistrictMap.map((d) => {
    const item = rankedRes.find((r: any) => r.name === d.name);
    d.value = item?.value ?? -1;
    d.rank = item?.rank;

    return d;
  });
};

// 科创概览-企业资质 企业列表
export const CompanyListAPI = async (params, qualificationType) => {
  let url;
  switch (qualificationType) {
    case '科创企业':
    case '科技型中小企业':
      url = '/api/company';
      break;

    default:
      // 其它资质 走农行数据定制接口
      url = '/api/qulification/especial';
      break;
  }

  let res: any[] = [];
  try {
    // res = await Request.post(url, params);
    res = [];
  } catch (error) {
    console.log('request error:', url, error);
  }

  return res;
};
